import React from "react";
import axios from '../../../util/http';
import * as url from '../../../util/api'
import { DatePicker, Select, Table, Checkbox } from 'antd';
import './EffectAnalysis.css'
const { RangePicker } = DatePicker;
const { Option } = Select;
export default class EffectAnalysis extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      data: []
    };
    this.columns = [
      {
        title: '活动名称',
        dataIndex: 'name',
      },
      {
        title: '活动类型',
        dataIndex: 'type',
      },
      {
        title: '关注统计',
        dataIndex: 'attention',
      },
      {
        title: '促销单统计',
        dataIndex: 'leaflet',
      },
    ];
  }
  handleChange(value) {
    console.log(`selected ${value}`);
  }
  onChange(pagination, filters, sorter, extra) {
    console.log('params', pagination, filters, sorter, extra);
  }
  onChangeCheck(e) {
    console.log(`checked = ${e.target.checked}`);
  }
  render() {
    let {data} =this.state
    return (
      <div>
        <div className={'xiaoguoHead'}>
          <RangePicker />
          <span>统计说明 导出</span>
        </div>
        <div className={'xiaoguoType'}>
          <div className={'Checkbox'}>
            <Select defaultValue="全部客户" style={{ width: 120 }} onChange={this.handleChange}>
              <Option value="全部客户">全部客户</Option>
              <Option value="只看新客">只看新客</Option>
              <Option value="只看老客">只看老客</Option>
            </Select>
            <Checkbox onChange={this.onChangeCheck}>按活动类型合并</Checkbox>
          </div>
          <div>
            <Table columns={this.columns} dataSource={data} onChange={this.onChange} />
          </div>
      
        </div>
      </div>
    );
  }
  componentDidMount() {
    axios({
      url: url.PostXgfxData,
      method: 'post'
    }).then(res => {
      console.log(res.data.data)
      let data = res.data.data.filter((item) => {
        item.key = item.id
        delete item.id
        return item
      })
      this.setState({
        data:data
      })
    })
  }
}
